import { _decorator, Component, Node, Game } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('AutoRotate')
export class AutoRotate extends Component {
    @property
    speed = 10;

    @property({ type: Node })
    fpsLabel = null;

    start() {        
    }

    update(deltaTime: number) {
        let y = this.node.eulerAngles.y + deltaTime * this.speed;
        this.node.setRotationFromEuler(this.node.eulerAngles.x, y, this.node.eulerAngles.z);

        var newLabel = this.fpsLabel.getComponent(cc.Label);
        newLabel.string = "FPS: " + Math.round(1 / deltaTime);
    }

    callback(event: Event, customEventData: string) {
        cc.game.setFrameRate(customEventData);
    }
}

